﻿using System;

namespace FpAgain.FP {
  
public variant Tree 
{
  | Sum { l : Tree; r : Tree }
  | Sin { op : Tree }
  | Variable { name : string }
  
  public override ToString() : string
  {
    def toString(tree) {
      | Tree.Variable(name) => name
      | Tree.Sin(op)        => $"sin($(toString(op)))"
      | Tree.Sum(a,b)       => $"$(toString(a))+$(toString(b))"
    }
    toString(this)
  }
}

}